package com.example.book.designmodel.责任链模式;

import java.util.List;

public class Chain {

    // 包含所有的具体handler链
    private List<AbstractHandler> handlerList;
    private int index = 0;

    public void doProcess() {
        if (index >= handlerList.size()) {
            return;
        }
        handlerList.get(index++).execute(this);
    }

    //ioc 注入
    public void setHandlerList(List<AbstractHandler> handlerList) {
        this.handlerList = handlerList;
    }
}
